import cv2
import matplotlib.pyplot as plt

plt.axis("off")
img = cv2.imread('img/example.png', 0)
# flipCode，0: 沿x轴镜像，>0: 沿y轴镜像，<0: 沿x轴和y轴都镜像
img_flipx = cv2.flip(img, flipCode=0)
img_flipy= cv2.flip(img, flipCode=1)
img_flipxy = cv2.flip(img, flipCode=-1)
plt.subplot(2, 3, 1)
plt.imshow(img, cmap='gray')
plt.axis('off')
plt.subplot(2, 3, 4)
plt.imshow(img_flipx, cmap='gray')
plt.axis('off')

plt.subplot(2, 3, 2)
plt.imshow(img, cmap='gray')
plt.axis('off')
plt.subplot(2, 3, 3)
plt.imshow(img_flipy, cmap='gray')
plt.axis('off')

plt.subplot(2, 3, 5)
plt.imshow(img, cmap='gray')
plt.axis('off')
plt.subplot(2, 3, 6)
plt.imshow(img_flipxy, cmap='gray')
plt.axis('off')

plt.show()
cv2.waitKey(0)